class AddIndex < ActiveRecord::Migration
  def self.up
    add_index :dictionaries,:index
    add_index :sense_details,:tid
    add_index :sense_details,[:position,:tid] ,:name => :position_tid_index
    add_index :dictionaries_sense_details,[:dictionary_id,:sense_detail_id],:name => :dictionary_id_sense_detail_id_index, :unique => true
    add_index :assigns, :dictionary_id
    add_index :assigns, :example_id
    add_index :assigns, [:dictionary_id,:example_id],:name => :dictionary_id_example_id_index
    add_index :assigns, [:dictionary_id,:example_id,:text_position],:name => :dictionary_id_example_id_text_position_index
    add_index :assigns, [:dictionary_id,:example_id,:sense_position],:name => :dictionary_id_example_id_sense_position_index
    add_index :examples,:text
  end

  def self.down
    remove_index :dictionaries,:index
    remove_index :sense_details,:tid
    remove_index :sense_details,:name => :position_tid_index
    remove_index :dictionaries_sense_details,:name => :dictionary_id_sense_detail_id_index
    remove_index :assigns, :dictionary_id
    remove_index :assigns, :example_id
    remove_index :assigns,:name => :dictionary_id_example_id_index
    remove_index :assigns,:name => :dictionary_id_example_id_text_position_index
    remove_index :assigns,:name => :dictionary_id_example_id_sense_position_index
    remove_index :examples,:text
  end
end
